import http from "@/http/index.ts"
import {Process, ProcessListParam, ProcessSon} from '@/api/process/type.ts'
import axios from 'axios';


// 新增工序
export const addApi = (data: Process) => {
    return http.post("/process/createProcess", data)
}


// 分页条件查询列表
export const getListApi = (data:ProcessListParam) => {
    return http.get("/process/getProcessList",data)
}

// 分页条件查询列表
export const getSonListApi = (data:ProcessListParam) => {
    return http.get("/process/getProcessSonList",data)
}


// 编辑
export const editApi = (data: Process) => {
    return http.put("/process/updateProcess", data)
}

// 删除
export const deleteApi = (id: number) => {
    return http.delete(`/process/deleteProcess/${id}`)
}

// 精简列表
export const getSimpleListApi = () => {
    return http.get("/process/simpleList")
}

// 新增工序
export const addSonApi = (data: ProcessSon) => {
    return http.post("/process/createProcessSon", data)
}

// 编辑
export const editSonApi = (data: ProcessSon) => {
    return http.put("/process/updateProcessSon", data)
}


// 删除
export const deleteSonApi = (id: number) => {
    return http.delete(`/process/deleteProcessSon/${id}`)
}

// 导出工序子项数据
export const exportProcessSonApi = (params: any) => {
    return axios.get('/api/process/exportProcessSon', {
        params,
        responseType: 'blob'
    })
}

// 导入工序子项数据
export const importProcessSonApi = (data: FormData) => {
    return http.upload('/process/importProcessSon', data)
}

// 下载工序子项导入模板
export const downloadProcessSonTemplateApi = () => {
    return axios.get('/api/process/downloadProcessSonTemplate', {
        responseType: 'blob'
    })
}